﻿using System.Collections.Generic;
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Dislocations2.App_Code
{
    public class Dislocation
{
    public int ID { get; set; }
    public int DateOp { get; set; }
    public int TimeOp { get; set; }
    public string Station { get; set; }
    public int Road1 { get; set; }
    public int Road2 { get; set; }
    public int IndexOfTr { get; set; }
    public int Numb { get; set; }

    public Dislocation(int id, int dateOp, int timeOp, string station, int road1, int road2, int indexOfTr, int numb)
    {
        ID = id;
        DateOp = dateOp;
        TimeOp = timeOp;
        Station = station;
        Road1 = road1;
        Road2 = road2;
        IndexOfTr = indexOfTr;
        Numb = numb;
    }
}

    
    public class Disl
    {
        DataTable dt;

        public DataTable LoadData()
        {            
            List<Dislocation> list = new List<Dislocation>();
            dt = new DataTable();

            list.Add(new Dislocation(55, 2, 3, "asd", 5, 6, 7, 8));
            list.Add(new Dislocation(9, 10, 11, "sdf", 13, 14, 15, 16));
            list.Add(new Dislocation(17, 18, 19, "B", 21, 22, 23, 24));
            list.Add(new Dislocation(25, 26, 27, "a1", 29, 30, 31, 32));
            list.Add(new Dislocation(33, 34, 35, "b2", 37, 38, 39, 40));
            list.Add(new Dislocation(41, 42, 43, "b3", 45, 46, 47, 48));
            list.Add(new Dislocation(49, 50, 51, "b3 2", 53, 54, 55, 56));
            list.Add(new Dislocation(57, 58, 59, "b3 1", 61, 62, 63, 64));
            list.Add(new Dislocation(65, 66, 67, "a", 69, 70, 1011, 72));
            list.Add(new Dislocation(73, 74, 1, "c", 77, 78, 79, 80));
            list.Add(new Dislocation(51, 3, 83, "z", 85, 86, 87, 88));
            list.Add(new Dislocation(89, 90, 91, "aoq", 93, 94, 95, 96));
            list.Add(new Dislocation(97, 98, 99, "mubg", 101, 102, 103, 104));
            list.Add(new Dislocation(105, 106, 107, "uew", 109, 110, 111, 112));
            list.Add(new Dislocation(113, 114, 115, "pos", 117, 118, 119, 120));
            list.Add(new Dislocation(121, 122, 123, "sos", 125, 126, 127, 128));
            list.Add(new Dislocation(129, 130, 131, "hz5", 133, 134, 135, 136));
            list.Add(new Dislocation(137, 138, 139, "pofins", 141, 142, 143, 144));
            list.Add(new Dislocation(145, 146, 147, "figudo", 149, 150, 151, 152));
            list.Add(new Dislocation(153, 154, 155, "ids", 157, 158, 159, 160));
            list.Add(new Dislocation(161, 162, 163, "fiug", 165, 166, 167, 168));
            list.Add(new Dislocation(169, 170, 171, "cudjf", 173, 174, 175, 176));
            list.Add(new Dislocation(177, 178, 179, "pvbi", 181, 182, 183, 184));
            list.Add(new Dislocation(185, 186, 187, "dp0fo", 189, 190, 191, 192));

            dt.Columns.Add(new DataColumn("Код операции", typeof(Int32)));
            dt.Columns.Add(new DataColumn("Дата операции", typeof(Int32)));
            dt.Columns.Add(new DataColumn("Время операции", typeof(Int32)));
            dt.Columns.Add(new DataColumn("Станция сверш. операции", typeof(string)));
            dt.Columns.Add(new DataColumn("Дорога сдачи", typeof(Int32)));
            dt.Columns.Add(new DataColumn("Дорога приема", typeof(Int32)));
            dt.Columns.Add(new DataColumn("Индекс поезда", typeof(Int32)));
            dt.Columns.Add(new DataColumn("Номер поезда", typeof(Int32)));

            for (int i = 0; i < 24; i++)
            {
                dt.Rows.Add(list[i].ID, list[i].DateOp, list[i].TimeOp, list[i].Station, list[i].Road1, list[i].Road2, list[i].IndexOfTr, list[i].Numb);
            }

            return dt;
        }

        public DataView SortData(string SortParam)
        {
            if (dt == null)
            {
                dt = LoadData();
            }
            if (SortParam == "")
                SortParam = "Код операции";

            DataView dv = new DataView(dt);
            dv.Sort = SortParam;
            return dv; 
        }
    }
}
